
package com.wit.witmg.util;

import lombok.Data;

import java.io.Serializable;

/**
 * JSON回应类
 *
 */
@Data
public class JsonPathResult implements Serializable {

    private Integer result = 1;// 1成功，-1失败
    private Integer status=0;//错误码
    private Object message = "成功";  // 提示语
    private String perlogo="https://cdniwallet.apisesame.com/";//CDN路径
//    private String path="http://192.168.16.101:8080/witunity/upload/soc/";//内网
//    private long total;// 数据总数
    /**
     * 构造函数
     */
    private JsonPathResult() {
    }


    private JsonPathResult(Object message) {
        this.message = message;
    }


    private JsonPathResult(Integer result, String msg) {
        this.result = result;
        this.message = msg;
    }

    private JsonPathResult(Integer result, Integer status, Object msg) {
        this.result = result;
        this.status = status;
        this.message = msg;
    }


    public static JsonPathResult success() {
        return new JsonPathResult();
    }

    public static JsonPathResult success(Object msg) {
        return new JsonPathResult(msg);
    }

    public static JsonPathResult success(Integer status, Object msg) {
        return new JsonPathResult(1,status,msg);
    }

    public static JsonPathResult error() {
        return new JsonPathResult(-1, "失败");
    }

    public static JsonPathResult error(String msg) {
        return new JsonPathResult(401, msg);
    }

    public static JsonPathResult error(Integer code, String msg) {
        return new JsonPathResult(code, msg);
    }

    public static JsonPathResult error(ErrorCode errorCode) {
        return new JsonPathResult(-1,errorCode.getCode(), errorCode.getMsg());
    }

}
